package com.ruoyi.common.utils;

import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chengliang
 * @date 2021/12/1
 * 对象复制工具类
 **/
public class CopyUtils {
    /**
     * 将doList转换为voList
     * @param poList
     * @param voClass
     * @return
     */
    public static List copyList (List <? extends Object> poList , Class voClass){
        List voList=new ArrayList();
        Object voObj =null;
        for(Object poObj:poList){
            try {
                voObj = voClass.newInstance();
            } catch (InstantiationException | IllegalAccessException e) {
                e.printStackTrace();
            }
            BeanUtils.copyProperties(poObj, voObj);
            voList.add(voObj);
        }
        return voList;
    }
}
